﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace UMLDesigner.Widgets
{
    public abstract class LinkWidget : UMLWidget
    {
        public abstract bool IsThisSourceWidgetOK(UMLWidget widget);
        public abstract bool IsThisDestinationWidgetOK(UMLWidget widget);

        public Slot SourceSlot
        {
            get;
            set;
        }

        public Slot DestinationSlot
        {
            get;
            set;
        }

        public UMLWidget SourceWidget
        {
            get;
            set;
        }

        public UMLWidget DestinationWidget
        {
            get;
            set;
        }

        public override Point Location
        {
            get
            {
                return SourceSlot.Location;
            }
            set
            {
                SourceSlot.Location = value;
            }
        }

        public override Size Size
        {
            get
            {
                Size size = new Size(Math.Abs(DestinationSlot.Location.X - SourceSlot.Location.X), Math.Abs(DestinationSlot.Location.Y - SourceSlot.Location.Y));
                return size;
            }
        }

        public void GetSlotsFromWigets()
        {
            SourceSlot = SourceWidget.AssignSlot(DestinationWidget);
            DestinationSlot = DestinationWidget.AssignSlot(SourceWidget);
        }


        protected void InitDefaultSlots()
        {
            SourceSlot = new Slot(new Point(0, 0), this);
            DestinationSlot = new Slot(new Point(0, 0), this);
        }
    }
}
